package com.ssh.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import com.ssh.dao.RoleDao;
import com.ssh.model.Role;

@Repository
public class RoleDaoImpl extends HibernateDaoSupport implements RoleDao {

	
	@Autowired
	public void setMySessionFactory(SessionFactory sessionFactory){
		super.setSessionFactory(sessionFactory);
	}
	
	public void saveRole(Role role) {
		// TODO Auto-generated method stub
		this.getHibernateTemplate().save(role);
	}

	public void updateRole(Role role) {
		// TODO Auto-generated method stub
		this.getHibernateTemplate().update(role);
	}

	public void deleteRole(Role role) {
		// TODO Auto-generated method stub
		this.getHibernateTemplate().delete(role);
	}

	public Role selectRole(Integer roleId) {
		// TODO Auto-generated method stub
		return this.getHibernateTemplate().get(Role.class, roleId);
	}

	public List<Role> selectAll(Role role) {
		// TODO Auto-generated method stub
		return this.getHibernateTemplate().find("from role");
	}
	
}
